//===- Linker.h -----------------------------------------------------------===//
//
//                     The MCLinker Project
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef ALONE_SUPPORT_LINKER_CONFIG_H
#define ALONE_SUPPORT_LINKER_CONFIG_H

#include <string>

#include <mcld/MC/MCLDInfo.h>
#include <mcld/Support/TargetRegistry.h>
#include <mcld/LD/DiagnosticLineInfo.h>
#include <mcld/LD/DiagnosticPrinter.h>

namespace alone {

class LinkerConfig {
private:
  //===--------------------------------------------------------------------===//
  // Available Configurations
  //===--------------------------------------------------------------------===//
  const std::string mTriple;
  bool mShared;
  std::string mSOName;

private:
  //===--------------------------------------------------------------------===//
  // These are generated by LinkerConfig during initialize().
  //===--------------------------------------------------------------------===//
  const mcld::Target *mTarget;
  bool initializeTarget();

  mcld::MCLDInfo *mLDInfo;
  bool initializeLDInfo();

  mcld::DiagnosticLineInfo *mDiagLineInfo;
  mcld::DiagnosticPrinter *mDiagPrinter;
  bool initializeDiagnostic();

public:
  //===--------------------------------------------------------------------===//
  // Getters
  //===--------------------------------------------------------------------===//
  inline const std::string &getTriple() const
  { return mTriple; }

  inline const mcld::Target *getTarget() const
  { return mTarget; }

  inline mcld::MCLDInfo* getLDInfo()
  { return mLDInfo; }

  inline const mcld::MCLDInfo* getLDInfo() const
  { return mLDInfo; }

  inline bool isShared() const
  { return mShared; }

  inline std::string getSOName() const
  { return mSOName; }

  void setShared(bool pEnable = true);

  void setBsymbolic(bool pEnable = true);

  void setSOName(const std::string &pSOName);

  void setDyld(const std::string &pDyld);

  void setSysRoot(const std::string &pSysRoot);

  void addWrap(const std::string &pWrapSymbol);

  void addPortable(const std::string &pPortableSymbol);

  void addSearchDir(const std::string &pDir);

public:
  LinkerConfig(const std::string& pTriple);

  virtual ~LinkerConfig();
};

} // end namespace alone

#endif // ALONE_SUPPORT_LINKER_CONFIG_H
